//
//  QYDataCell.swift
//  QingYuJSQ
//
//  Created by 李东 on 2024/4/5.
//

import UIKit

class QYDataCell: UITableViewCell {
    
    @IBOutlet weak var weekLabel: UILabel!
    @IBOutlet weak var dayLabel: UILabel!
    @IBOutlet weak var emotionImgView: UIImageView!
    @IBOutlet weak var emptionLabel: UILabel!
    @IBOutlet weak var timeLabel: UILabel!
    @IBOutlet weak var contentLabel: UILabel!
    @IBOutlet weak var picImgView: UIImageView!
    
    @IBOutlet weak var timeLabel_height: NSLayoutConstraint!

    @IBOutlet weak var contentLabel_top: NSLayoutConstraint!
    
    @IBOutlet weak var pic_top: NSLayoutConstraint!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    var model: QYDataModel! {
        didSet {
            weekLabel.text = model.week
            dayLabel.text = model.date
            emotionImgView.image = UIImage(named: model.emotion)
            emptionLabel.text = model.emotion
            timeLabel.text = model.time
            contentLabel.text = model.content
            picImgView.image = UIImage(contentsOfFile: CompressedHelper.shared.getFilePath(fileName: model.fileName))
            if model.time.isEmpty {
                timeLabel_height.constant = 0
                contentLabel_top.constant = 0
            }else{
                timeLabel_height.constant = 17
                contentLabel_top.constant = 15
            }
            if model.content.isEmpty {
                pic_top.constant = 0
            }else{
                pic_top.constant = 20
            }
        }
    }
}
